<%@ page import="Models.enity.Pagination" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="">

    <title>运行保障系统</title>

    <!-- Bootstrap core CSS -->
    <link href="/asset/css/bootstrap.css" rel="stylesheet">

    <!-- Add custom CSS here -->
    <link href="/asset/css/sb-admin.css" rel="stylesheet">

    <link rel="stylesheet" href="/asset/font-awesome/css/font-awesome.min.css">
    <!-- Page Specific CSS -->
    <link rel="stylesheet" href="/asset/css/morris-0.4.3.min.css">
</head>

<body>

<div id="wrapper">

    <nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
        <!-- Brand and toggle get grouped for better mobile display -->
        <div class="navbar-header">
            <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-collapse">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand" href="/index">运行保障系统</a>
        </div>

        <div class="collapse navbar-collapse navbar-ex1-collapse">
            <ul class="nav navbar-nav side-nav">
                <li class="dropdown">
                    <a href="#" class="dropdown-toggle" data-toggle="dropdown"><i class="fa fa-caret-square-o-down"></i> 工作空间 <b class="caret"></b></a>
                    <ul class="dropdown-menu">
                        <li><a href="/transactional/eventHandle">事务处理</a></li>
                        <li><a href="/transactional/orderHandle">订单处理</a></li>
                        <li ><a href="/transactional/NeweventHandle">新事务处理</a></li>
                        <li><a href="/transactional/orderRequest">物品订购申报</a></li>
                    </ul>
                </li>
                <li class="dropdown">
                    <a href="#" class="dropdown-toggle" data-toggle="dropdown"><i class="fa fa-caret-square-o-down"></i> 统计信息 <b class="caret"></b></a>
                    <ul class="dropdown-menu">
                        <li><a href="/message/history">事务历史</a></li>
                    </ul>
                </li>
                <li class="active"><a href="/announcement"><i class="fa fa-table"></i> 系统公告</a></li>
                <li><a href="/changePass"><i class="fa fa-edit"></i> 密码修改</a></li>
            </ul>
            <ul class="nav navbar-nav navbar-right navbar-user">
                <li class="dropdown user-dropdown">
                    <a href="#" class="dropdown-toggle" data-toggle="dropdown"><i class="fa fa-user"></i> 管理员 <b class="caret"></b></a>
                    <ul class="dropdown-menu">
                        <li><a href="/logout"><i class="fa fa-power-off"></i> 退出</a></li>
                    </ul>
                </li>
            </ul>
        </div><!-- /.navbar-collapse -->
    </nav>


    <div id="page-wrapper">
        <div class="row">
            <div class="col-lg-12">
                <h1>系统公告</h1>
                <ol class="breadcrumb">
                    <li><a href="/index"><i class="fa fa-dashboard"></i> 首页</a></li>
                    <li class="active"><i class="fa fa-edit"></i> 系统公告</li>
                </ol>
                <a href="/announcement/create" class="btn btn-primary">写新公告</a>
                <hr />

                <div class="panel panel-primary">
                    <div class="panel-heading">
                        <h3 class="panel-title"><i class="fa fa-bar-chart-o"></i> 最近一周的公告</h3>
                    </div>
                    <div class="panel-body">
                        <div class="flot-chart">
                            <div class="flot-chart-content" id="flot-chart-line">
                                <c:forEach items="${requestScope.announcements}" var="a">
                                    <p style="color: red;font-size: 17px;">
                                        <strong> >> &nbsp;&nbsp;&nbsp;</strong>
                                        ${a.department} &nbsp;&nbsp;&nbsp;
                                        ${a.created_at} &nbsp;&nbsp;&nbsp;
                                        发表公告:${a.content}
                                    </p>
                                </c:forEach>
                            </div>
                        </div>
                    </div>
                </div>

                <table class="table table-bordered table-hover tablesorter">
                    <thead>
                    <tr>
                        <th>公告发布部门 </th>
                        <th>公告内容 </th>
                        <th>发布时间 </th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    <c:forEach items="${pagination.getPageData()}" var="a">
                        <tr>
                            <td>${a.department}</td>
                            <td>${a.content}</td>
                            <td>${a.created_at}</td>
                            <td><a href="/announcement/delete?id=${a.id}" class="btn btn-primary">删除</a></td>
                        </tr>
                    </c:forEach>
                    </tbody>
                </table>

                <ul class="pagination" style="margin: 0 auto;">
                    <li><a href="<%
                        Pagination obj1 =(Pagination) request.getAttribute("pagination");
                        int tmp = (obj1.getCurrentPage() - 1);
                        if (tmp<=0) tmp = 1;
                        out.println("/announcement?page="+tmp);
                        %>">&laquo;</a></li>
                    <%
                        Pagination obj =(Pagination) request.getAttribute("pagination");
                        int pageSize = obj.AllPages;
                        for (int a = 1 ;a<=pageSize;a++){
                            if (obj.getCurrentPage() == a){
                                out.println("<li class=\"active\"><a href=\"/announcement?page="+a+"\">"+a+"</a></li>");
                            }else {
                                out.println("<li><a href=\"/announcement?page="+a+"\">"+a+"</a></li>");
                            }
                        }
                    %>
                    <li><a href="<%
                        Pagination obj2 =(Pagination) request.getAttribute("pagination");
                        int tmp2 = (obj2.getCurrentPage() + 1);
                        if (tmp2>=obj2.AllPages) tmp2=obj2.AllPages;
                        out.println("/announcement?page="+tmp2);
                        %>">&raquo;</a></li>
                </ul>

            </div>
        </div><!-- /.row -->



    </div>
</div><!-- /#wrapper -->

<!-- JavaScript -->
<script src="/asset/js/jquery-1.10.2.js"></script>
<script src="/asset/js/bootstrap.js"></script>

<!-- Page Specific Plugins -->    <script src="/asset/js/raphael-min.js"></script>
<script src="/asset/js/morris-0.4.3.min.js"></script>
<script src="/asset/js/morris/chart-data-morris.js"></script>
<script src="/asset/js/tablesorter/jquery.tablesorter.js"></script>
<script src="/asset/js/tablesorter/tables.js"></script>
</body>
</html>